package com.oocl.euc.core.builder;

import com.oocl.euc.core.maintenance.model.TeamEndorser;
import com.oocl.euc.core.maintenance.model.Users;
import com.oocl.euc.core.maintenance.repository.TeamEndorserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TeamEndorserBuilder {
    private TeamEndorser teamEndorser;

    @Autowired
    private TeamEndorserRepository teamEndorserRepository;

    public TeamEndorserBuilder defaultBuilder() {
        this.teamEndorser = new TeamEndorser();
        return this;
    }

    public TeamEndorserBuilder withEndorser(String endorser){
        this.teamEndorser.setEndorser(endorser);
        return this;
    }

    public TeamEndorserBuilder withUser(Users user){
        this.teamEndorser.setUsers(user);
        return this;
    }

    public TeamEndorserBuilder withDisplayName(String displayName){
        this.teamEndorser.setDisplayName(displayName);
        return this;
    }

    public TeamEndorser create() {
        return this.teamEndorser;
    }

    public TeamEndorser saveToDB(){
        teamEndorserRepository.save(this.teamEndorser);
        return this.teamEndorser;
    }
}
